<template>
  <div class="app-container" v-loading="pageLoading">
    <el-button type="primary" class="fr" @click="exportData" :loading="exportLoading">导出</el-button>
    <div class="filter-container">

      <el-date-picker class="filter-item" style="width: 250px" v-model="time" type="daterange" range-separator="-"
        start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss">
      </el-date-picker>
      <el-select class="filter-item" style="width: 200px" v-model="query.querystring.rqirt_line" placeholder="选择线体"
        filterable clearable @change='research'>
        <el-option v-for="v in lineData" :key="v.id" :label="v.line_name" :value="v.line_name"> </el-option>
      </el-select>

      <el-input style="width: 200px" placeholder="产品型号编码" clearable prefix-icon="el-icon-search" class="filter-item"
        @keyup.enter.native="research" @clear="research" v-model="query.querystring.rqirt_finishedproduct_code">
      </el-input>
      <el-input style="width: 200px" placeholder="工单号" clearable prefix-icon="el-icon-search" class="filter-item"
        @keyup.enter.native="research" @clear="research" v-model="query.querystring.rqirt_order_no">
      </el-input>
      <el-select class="filter-item" style="width: 100px" v-model="query.querystring.rqirt_result" placeholder="检测结果"
        filterable clearable @change='research'>
        <el-option label="ALL" value=""></el-option>
        <el-option label="OK" value="OK"></el-option>
        <el-option label="NG" value="NG"></el-option>
      </el-select>
      <el-button class="filter-item" type="success" plain @click="research">查询</el-button>
      <el-button class="filter-item" type="warning" plain @click="reset">重置</el-button>

    </div>
    <z-table :list="list" :tableProps="tableProps" :columns="columns" @editItem="editItem" @deleteItem="deleteItem">
    </z-table>
    <z-pagination :pagination="pagination" :total="total" :page.sync="query.page" :limit.sync="query.size"
      @change="getList"></z-pagination>
  </div>
</template>

<script>
import commonMixin from '@/views/_common/mixin'
export default {
  mixins: [commonMixin],
  name: 'detailed',
  data: function () {
    return {
      apiList: this.$api.massList + 'getallrqlist',
      name: '品质明细报表',
      tableProps: {
        border: true,
        opsColWith: 85,
      },
      query: {
        page: 1,
        size: 10,
        querystring: {},
      },
      tableProps: {
        hideOperations: true,
      },
      lineData: [],
      time: [],
      columns: [
        { title: '工单编号', key: 'rqirt_order_no' },
        { title: 'SN', key: 'rqirt_sn' },
        { title: '成品型号', key: 'rqirt_finishedproduct_code' },
        { title: '产线', key: 'rqirt_line' },
        { title: '检测项目', key: 'rqirt_test_items' },
        { title: 'SPEC下限', key: 'rqirt_spec_lowerlimit' },
        { title: 'SPEC上限', key: 'rqirt_spec_upperlimit' },
        { title: '检测值', key: 'rqirt_detection_value' },
        { title: '结果判定', key: 'rqirt_result' },
        { title: '检测日期', key: 'rqirt_time' },
        { title: '检测时间', key: 'modify_time' },
      ],
    }
  },
  created: function () {
    this.getList(),
      this.$request(this.$api.line + 'getlistbypage', { page: 1, size: 999 }).then((r) => {
        console.log(r)
        this.lineData = r.list
      })
  },
  methods: {
    research() {
      if (!this.time) {
        this.query.querystring.rqirt_time_start = ''
        this.query.querystring.rqirt_time_end = ''
      } else {
        this.query.querystring.rqirt_time_start = this.time[0]
        this.query.querystring.rqirt_time_end = this.time[1]
      }
      this.query.page = 1
      this.list = []
      this.total = 0
      console.log(this.query)
      this.getList()
    },
    reset() {
      this.time = []
      this.query.querystring = {}
      this.getList()
    },
  },
}
</script>
<style scoped lang='scss'>
</style>